﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using BudgetManager.Domain;
using Microsoft.Phone.Shell;

namespace BudgetManager
{
    public partial class CategoryExpense : PhoneApplicationPage
    {

        public CategoryExpense()
        {
            InitializeComponent();

        }

        private void onOk(object sender, EventArgs e)
        {
           PhoneApplicationService.Current.State["Category"] = userControlCategories.SelectedCategory;
            NavigationService.Navigate(new Uri(string.Format("/Expense.xaml?"), UriKind.Relative));
        }

        private void onCancel(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri(string.Format("/Expense.xaml?"), UriKind.Relative));
        }

        private void onAddNew(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri(string.Format("/ManagementCategory.xaml?"), UriKind.Relative));
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.NavigationMode == System.Windows.Navigation.NavigationMode.Back)
            {
                userControlCategories.RefreshCategories();
            }

        }
    }
}